<!--
  @author liuying
  @date 2018/11/21 15:36
-->
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">
<html th:replace="~{work/modify/common/layout :: layout('false', ~{::title}, ~{::content}, ~{::script})}">
<head>
    <title>工单-修改</title>

</head>
<body>

<body>

    <div th:fragment="content">
        <div class="layui-fluid new-order-page">
        <div class="layui-card">
            <form id="updateOrderAction" method="post" th:action="'/work/modify/member/save.action?opType=' + ${opType}" class="layui-form" lay-filter="zmn-order-add-form">
                <input type="hidden" name="workId" id="work-id" th:value="${workId}"/>
                <input type="hidden" name="orderId"  id="order-id" th:value="${orderId}"/>

                <input type="hidden" name="longitude" id="longitude" th:value="${orderInfo.longitude}"/>
                <input type="hidden" name="latitude"  id="latitude" th:value="${orderInfo.latitude}"/>

                <!-- 新单 -->
                <input type="hidden" name="type" id="type" th:value="1"/>
                <!--地址info-->
                <input type="hidden" id="streetSource" name="streetSource" th:value="${orderInfo.streetSource}">
                <input type="hidden" id="communityId" th:value="${orderInfo.streetId}">
<!--                <input type="hidden" name="provinceId" th:value="${orderInfo.provinceId}"/>-->
<!--                <input type="hidden" name="cityId" th:value="${orderInfo.cityId}"/>-->

                <!--<div class="layui-card-header" style="margin-top:10px;"><b>基本信息</b></div>-->
                <div class="layui-split">&nbsp;</div>

                <div th:with="product=${orderInfo.orderProductList[0]}">
                    <!-- 联系电话 -->
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">联系电话</label>
                            <div class="layui-input-inline" style="width: 200px;">
                                <!-- 联系电话1 -->
                                <th:block th:replace="common/_orderAddTmpl :: inputOfTelephone1ForMember"/>
                            </div>
                            <label class="layui-form-label">联系电话</label>
                            <div class="layui-input-inline" style="width: 200px;">
                                <!-- 联系电话2 -->
                                <input class="layui-input"
                                       id="telephone2"
                                       type="text"
                                       name="telephone2"
                                       lay-verify="tel"
                                       placeholder="电话02"
                                       autocomplete="off"
                                       th:value="${orderInfo.telephone2}">
                            </div>
                            <div class="layui-input-inline" style="width: 200px;">
                                <!-- 联系电话3 -->
                                <input class="layui-input"
                                       id="telephone3"
                                       type="text"
                                       name="telephone3"
                                       lay-verify="tel"
                                       placeholder="电话03"
                                       autocomplete="off"
                                       th:value="${orderInfo.telephone3}">
                            </div>
                            <div class="layui-form-mid layui-word-aux"><a id="btn-equity" href="">会员权益 <i class="layui-icon layui-icon-down"></i></a></div>
                        </div>
                    </div>
                    <!-- 用户姓名、下单渠道 -->
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label layui-form-required">客户姓名</label>
                            <div class="layui-input-inline" style="width: 200px;">
                                <th:block th:replace="common/_orderAddTmpl :: inputOfUserNameForMember"/>
                            </div>
                            <label class="layui-form-label layui-hide">下单渠道</label>
                            <div class="layui-input-inline layui-hide" style="width: 410px;">
                                <select id="channelId" name="channelId" lay-verify="required" lay-filter="channelId" lay-search>
                                    <option th:each="channel : ${channelList}"
                                            th:value="${channel.value}"
                                            th:selected="${channel.selected == true}"
                                            th:text="${channel.text}">
                                    </option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <!-- 用户性别 -->
                    <div class="layui-form-item">
                        <label class="layui-form-label"></label>
                        <div class="layui-input-block" >
                            <input type="radio"
                                   name="gender"
                                   th:each="item : ${gender}"
                                   th:value="${item.value}"
                                   th:title="${item.text}"
                                   th:checked="${item.value == orderInfo.gender}"
                                   lay-verify="required">
                        </div>
                    </div>
                    <!-- 用户地址-省、市 -->
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">用户地址</label>
                            <div class="layui-input-inline" style="width: 200px;">
                                <select id="provinceId" name="provinceId" lay-verify="required" lay-filter="province" lay-search disabled>
                                    <option value="">省</option>
                                    <option th:each="province : ${provinceList}"
                                            th:value="${province.value}"
                                            th:text="${province.text}"
                                            th:selected="${province.value == orderInfo.provinceId}">
                                </select>
                            </div>
                            <div class="layui-input-inline" style="width: 295px;">
                                <select id="cityId" name="cityId" lay-verify="required" lay-filter="city" lay-search disabled>
                                    <option value="">市</option>
                                    <option th:each="city : ${cityList}"
                                            th:value="${city.value}"
                                            th:text="${city.text}"
                                            th:selected="${city.value == orderInfo.cityId}">
                                    </option>
                                </select>
                            </div>
                            <div class="layui-form-mid layui-word-aux">
                                <span id="company" class="company" th:text="${orderInfo.manageCompanyName}"></span>
                            </div>
                        </div>
                    </div>

                    <!-- 用户地址-区县、街道 -->
                    <div id="fuzzy-address" class="layui-form-item"  th:classappend="${(orderInfo.streetSource == 0 && orderInfo.streetId == 0) || orderInfo.streetSource != 3} ? 'layui-hide'">
                        <div class="layui-inline">
                            <label class="layui-form-label"></label>
                            <div class="layui-input-inline" style="width: 200px;">
                                <select id="countyId" name="countyId" lay-filter="countyId" lay-search  th:value="${orderInfo.countyId}">
                                    <option value="">请选择区县</option>
                                    <option th:each="county : ${countyList}"
                                            th:value="${county.value}"
                                            th:text="${county.text}"
                                            th:selected="${county.value == orderInfo.countyId}">
                                    </option>
                                </select>
                            </div>
                            <div class="layui-input-inline" style="width: 295px;">
                                <select id="streetId"
                                        name="streetId"
                                        lay-filter="streetId"
                                        lay-search
                                        th:value="${orderInfo.streetId}">
                                    <option value="">请选择乡镇或街道</option>
                                    <option th:each="street : ${streetList}"
                                            th:value="${street.areaId}"
                                            th:text="${street.name}"
                                            th:data-longitude="${street.longitude}"
                                            th:data-latitude="${street.latitude}"
                                            th:selected="${street.areaId == orderInfo.streetId}">
                                    </option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <!-- 用户地址-map -->
                    <div id="exact-address" class="layui-form-item" th:classappend="${(orderInfo.streetSource == 0 && orderInfo.streetId != 0) || orderInfo.streetSource == 3} ? 'layui-hide'">
                        <div class="layui-inline">
                            <label class="layui-form-label" ></label>
                            <div class="layui-input-inline input-large" id="street-wrapper">
                                <input class="layui-input layui-disabled"
                                       id="customerAddress"
                                       type="text"
                                       name="street"
                                       lay-verify="required"
                                       placeholder="搜索地点，选择小区，街道，大厦..."
                                       autocomplete="off"
                                       style="padding-right: 95px;"
                                       th:value="${orderInfo.street}"
                                       readonly>
                                <button id="btn-map" class="layui-btn layui-btn-normal layui-hide" style="position: absolute;top: 0;right: 0;">百度地图</button>
                                <div id="suggestPanel" class="suggestPanelBox layui-anim layui-anim-upbit">
                                    <ul></ul>
                                </div>
                            </div>
                            <div class="layui-inline">
                                <div class="layui-input-inline" id="county-list">
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- 用户地址-门牌 -->
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label"></label>
                            <div class="layui-input-inline input-large">
                                <input class="layui-input layui-disabled"
                                       type="text"
                                       name="address"
                                       th:value="${orderInfo.address}"
                                       maxlength="100"
                                       placeholder="请输入详细楼栋、门牌号"
                                       autocomplete="off"
                                       lay-verify="required"
                                       readonly>
                            </div>
                        </div>
                    </div>
                    <!-- 切换精确地址与模糊地址 -->
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label"></label>
                            <div class="layui-input-inline input-large">
                                <a class="btn-duty-time"  th:classappend="${(orderInfo.streetSource == 0 && orderInfo.streetId != 0) || orderInfo.streetSource == 3} ? 'layui-hide'" id="address-type-exact" href="javascript:void(0);">无法找到精确地址</a>
                                <a class="btn-duty-time"  th:classappend="${(orderInfo.streetSource == 0 && orderInfo.streetId == 0) || orderInfo.streetSource != 3} ? 'layui-hide'" id="address-type-fuzzy" href="javascript:void(0);" >切换为精确地址</a>
                            </div>
                        </div>
                    </div>
                    <!-- 服务分类、订单类型 -->
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">服务分类</label>
                            <div class="layui-input-inline" style="width: 200px;">
                                <select id="servCategoryId"
                                        name="servCategId"
                                        lay-verify="required"
                                        lay-filter="servCategory"
                                        lay-search
                                        th:disabled="${disabledFields.contains('servCategId')}">
                                    <option value="">全部</option>
                                    <option th:each="item : ${servCategList}"
                                            th:value="${item.value}"
                                            th:text="${item.text}"
                                            th:selected="${item.value == orderInfo.servCategId}">
                                    </option>
                                </select>
                            </div>

                            <div class="layui-input-inline layui-hide" >
                                <input type="radio"
                                       name="productShowType"
                                       th:each="item : ${productShowType}"
                                       th:value="${item.value}"
                                       th:title="${item.text}"
                                       th:checked="${item.value} == 1"
                                       lay-verify="required"
                                       lay-filter="product-showtype">
                            </div>
                        </div>
                    </div>
                    <!-- 服务产品、产品数量、品牌 -->
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label" >服务产品</label>
                            <div class="layui-input-inline" style="width: 200px;">
                                <select class="product-select"
                                        id="product"
                                        name="productId"
                                        lay-verify="required"
                                        lay-filter="product"
                                        lay-search
                                        th:disabled="${disabledFields.contains('productId')}">
                                    <option value=""></option>
                                    <option th:each="item : ${servProductList}"
                                            th:value="${item.value}"
                                            th:text="${item.text}"
                                            th:selected="${item.value == product.productId}">
                                </select>
                            </div>
                            <label class="layui-form-label" >产品数量</label>
                            <div class="layui-input-inline" style="width: 200px;">
                                <input class="layui-input"
                                       id="count"
                                       type="text"
                                       name="number"
                                       placeholder="请填写数量"
                                       autocomplete="off"
                                       min="1"
                                       max="10"
                                       lay-verify="required|count"
                                       th:value="${product.number}"
                                       style="padding-right: 40px"
                                       th:disabled="${disabledFields.contains('productNumber')}">
                                <span class="order-number-unit" id="unit" th:text="${(product.productUnit != null && product.productUnit != '')? product.productUnit : product.showProductUnit}"></span>
                            </div>
                            <div class="layui-input-inline" style="width: 200px;">
                                <select id="brand" name="brandId" lay-filter="brand" lay-search>
                                    <option value="">品牌</option>
                                    <option th:each="item : ${brandList}"
                                            th:value="${item.value}"
                                            th:text="${item.text}"
                                            th:selected="${item.value == product.brandId}">
                                </select>
                            </div>
                            <div class="layui-form-mid layui-word-aux">权益：<span id="equity-name" th:text="${orderMemEquityVO.equityTypeName}"></span></div>
                        </div>
                    </div>
                    <!-- 常见故障 -->
                    <div class="layui-form-item" th:styleappend="${subsidiaryList == null || subsidiaryList.isEmpty() } ? 'display: none' ">
                        <div class="layui-inline">
                            <label class="layui-form-label" >常见故障</label>
                            <div class="layui-input-block faults-wrapper" id="faults-wrapper">
                                <input type="checkbox"
                                       name="faultIdList"
                                       lay-skin="primary"
                                       th:each="fault : ${subsidiaryList}"
                                       th:title="${fault.text}"
                                       th:value="${fault.value}"
                                       th:checked="${product.faultIdList != null && product.faultIdList.contains(fault.value)}">
                            </div>
                        </div>
                    </div>
                    <!-- 其他故障 -->
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">其他故障</label>
                            <div class="layui-input-inline" style="width: 725px;">
                                    <textarea class="layui-textarea"
                                              id="fault-remark"
                                              name="faultRemark"
                                              th:text="${product.remark}"
                                              placeholder="最长不能超过300个字"
                                              maxlength="300"
                                              lay-verify="maxLenTo300"></textarea>
                            </div>
                        </div>
                    </div>
                    <!-- 会员权益 -->
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">会员权益</label>
                            <div class="layui-input-inline" style="width: 725px;">
                                <input type="radio"
                                       id = "equityType"
                                       name="equityType"
                                       th:each="item : ${memberEquityList}"
                                       th:value="${item.value}"
                                       th:title="${item.text}"
                                       th:checked="${item.selected}"
                                       th:disabled="${item.disabled}"
                                       lay-verify="required"
                                       lay-filter="member-equity">
                            </div>
                        </div>
                    </div>
                    <!-- 应付总价 -->
                    <div class="layui-form-item" id="amount-wrapper" style="display: none;">
                        <div class="layui-inline">
                            <label class="layui-form-label">应付总价</label>
                            <div class="layui-input-inline" style="width: 725px;">
                                <span id="amount" style="color: red;"></span>元
                                <button class="layui-btn" style="padding: 0;"></button>
                            </div>
                        </div>
                    </div>
                    <!-- 预约时间 -->
                    <div class="layui-form-item input-duty-time" th:with="dutyTime=${#dates.format(orderInfo.dutyTime, 'yyyy-MM-dd HH:mm:ss')}">
                        <div class="layui-inline">
                            <label class="layui-form-label">预约时间</label>
                            <div class="layui-input-inline layui-inline-text" id="duty-time-wrapper">
                                <span id="duty-time" th:text="${dutyTime}"></span>
                                <a class="btn-duty-time" id="btn-duty-time" href="javascript:void(0);" th:if="${disabledFields.contains('operateDutyTime')}">选择预约时间</a>
                                <button class="layui-btn" style="padding: 0;"></button>
                                <input id="duty-time-input"
                                       type="hidden"
                                       name="dutyTime"
                                       th:value="${dutyTime}"
                                       lay-verify="dutyTime"
                                       style="padding: 0;">
                            </div>
                            <div class="layui-input-inline" th:if="${!disabledFields.contains('dutyFail')}">
                                <input id="duty-time-checkbox"
                                       type="checkbox"
                                       name=""
                                       lay-filter="duty-time-checkbox"
                                       title="客户不确定上门时间"
                                       lay-skin="primary">
                            </div>
                        </div>
                    </div>
                    <!-- 下单备注 -->
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">下单备注</label>
                            <div class="layui-input-block input-large">
                                    <textarea class="layui-textarea"
                                              name="remark"
                                              maxlength="500"
                                              placeholder="最长不能超500个字"
                                              th:text="${orderInfo.remark}"
                                              lay-verify="maxLenTo500"></textarea>
                            </div>
                            <span style="color: red;">注意：此处备注工程师APP、用户可见。</span>
                        </div>
                    </div>
                    <!-- 按钮 -->
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <div>
                                <button id="confirmbtn" type="submit" class="layui-btn" lay-submit lay-filter="confirmbtn">保存</button>
                                <!--<button type="reset" class="layui-btn layui-btn-primary" >重置</button>-->
                            </div>
                        </div>
                    </div>
                    <div style="height: 1px"></div>
                </div>
            </form>
        </div>
    </div>
    </div>

    <!-- 会员权益 -->
    <script th:inline="javascript" id="tpl-panel-equity" type="text/html">
        <div id="panel-equity" style="padding: 20px; background-color: #F2F2F2;">
            <div class="layui-row layui-col-space15">
                {{#  layui.each(d.memOrderEquityList, function(index, item){ }}
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-header" style="padding: 10px 15px; height: auto; line-height: 25px;">
                            {{#  if(item.equityType == 1){ }}
                            <p>会员产品：{{d.memProductName}}</p>
                            <p>会员有效期：{{d.effectTime}}-{{d.expiredTime}}</p>
                            <p>原单产品：{{d.workProductName}}</p>
                            {{#  } }}
                        </div>
                        <div class="layui-card-body">
                            <div>会员权益</div>
                            <div>
                                权益：
                                {{#  if(item.equityType == 1){ }}
                                {{item.equityTypeName}}，
                                享有：{{layui.NP.formatMoneyToYuan(item.buyReductionValue)}} 额度
                                {{#  } }}
                                {{#  if(item.equityType == 3){ }}
                                {{item.equityTypeName}}，
                                赠送次数：{{item.buyGivNum}} ，
                                剩余：{{item.givNum}}次
                                {{#  } }}
                                {{#  if(item.equityType == 4){ }}
                                {{item.equityTypeName}}，
                                折扣：{{item.discountValue/10}}折
                                {{#  } }}
                                {{#  if(item.equityType == 5){ }}
                                {{item.equityTypeName}}，
                                {{item.title}}
                                {{#  } }}
                            </div>
                        </div>
                    </div>
                </div>
                {{#  }); }}
                {{#  if(d.equityList === 0){ }}
                无数据
                {{#  } }}
            </div>
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-header">
                            权益使用
                        </div>
                        <div class="layui-card-body">
                            {{#  layui.each(d.userEquityInfoList, function(index, item){ }}
                            <p> {{item}} </p>
                            {{#  }); }}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </script>

    <script th:inline="javascript">
        var json = {
            cityList: [[${cityList}]]
        };

        var layuiModel = {
            oms_mermber_order_update: "member/order/zmn.oms.mermber.order.update"
        };
    </script>
</body>
</html>